﻿<Window
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	x:Class="Microsoft.Research.ScientificWorkflow.ManagementStudioControls.RegistryManagerModule.SelectGroup"
	x:Name="Window"
	Width="300" Height="250" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d"
     WindowStyle="None" Background="{x:Null}" ResizeMode="NoResize" ShowInTaskbar="False"  WindowStartupLocation="CenterOwner" AllowsTransparency="True" >

	<Window.Resources>
        <BooleanToVisibilityConverter x:Key="VisibilityConverter"></BooleanToVisibilityConverter>
        <Style x:Key="PopupCloseButton" BasedOn="{x:Null}" TargetType="{x:Type Button}">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type Button}">
						<Grid>
							<Rectangle Fill="#FFCCCCCC" Stroke="{x:Null}" RadiusX="4.5" RadiusY="4.5" x:Name="rectangle"/>
							<Rectangle Fill="#FF4F4F4F" Stroke="{x:Null}" RadiusX="0" RadiusY="0" Margin="8,3.5,7,3.5" RenderTransformOrigin="0.5,0.5">
								<Rectangle.RenderTransform>
									<TransformGroup>
										<ScaleTransform ScaleX="1" ScaleY="1"/>
										<SkewTransform AngleX="0" AngleY="0"/>
										<RotateTransform Angle="-34.039"/>
										<TranslateTransform X="0" Y="0"/>
									</TransformGroup>
								</Rectangle.RenderTransform>
							</Rectangle>
							<Rectangle Fill="#FF4F4F4F" Stroke="{x:Null}" RadiusX="0" RadiusY="0" RenderTransformOrigin="0.5,0.5" Margin="8,3.5,7,3.5">
								<Rectangle.RenderTransform>
									<TransformGroup>
										<ScaleTransform ScaleX="-1" ScaleY="1"/>
										<SkewTransform AngleX="0" AngleY="0"/>
										<RotateTransform Angle="34.039"/>
										<TranslateTransform X="0" Y="0"/>
									</TransformGroup>
								</Rectangle.RenderTransform>
							</Rectangle>
						</Grid>
						<ControlTemplate.Triggers>
							<Trigger Property="IsFocused" Value="True"/>
							<Trigger Property="IsDefaulted" Value="True"/>
							<Trigger Property="IsMouseOver" Value="True">
								<Setter Property="Fill" TargetName="rectangle" Value="#FFADADAD"/>
							</Trigger>
							<Trigger Property="IsPressed" Value="True"/>
							<Trigger Property="IsEnabled" Value="False"/>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		<Style x:Key="TreeViewItemFocusVisual">
			<Setter Property="Control.Template">
				<Setter.Value>
					<ControlTemplate>
						<Rectangle/>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		<PathGeometry x:Key="TreeArrow" Figures="M0,0 L0,6 L6,0 z"/>
		<Style x:Key="ExpandCollapseToggleStyle" TargetType="{x:Type ToggleButton}">
			<Setter Property="Focusable" Value="False"/>
			<Setter Property="Width" Value="16"/>
			<Setter Property="Height" Value="16"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type ToggleButton}">
						<Border Width="16" Height="16" Background="Transparent" Padding="5,5,5,5">
							<Path Fill="Transparent" Stroke="#FF989898" x:Name="ExpandPath" Data="{StaticResource TreeArrow}">
								<Path.RenderTransform>
									<RotateTransform Angle="135" CenterX="3" CenterY="3"/>
								</Path.RenderTransform>
							</Path>
						</Border>
						<ControlTemplate.Triggers>
							<Trigger Property="IsMouseOver" Value="True">
								<Setter Property="Stroke" TargetName="ExpandPath" Value="#FF1BBBFA"/>
								<Setter Property="Fill" TargetName="ExpandPath" Value="Transparent"/>
							</Trigger>
							<Trigger Property="IsChecked" Value="True">
								<Setter Property="RenderTransform" TargetName="ExpandPath">
									<Setter.Value>
										<RotateTransform Angle="180" CenterX="3" CenterY="3"/>
									</Setter.Value>
								</Setter>
								<Setter Property="Fill" TargetName="ExpandPath" Value="#FF595959"/>
								<Setter Property="Stroke" TargetName="ExpandPath" Value="#FF262626"/>
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		<Style x:Key="TreeViewItemStyleUser" TargetType="{x:Type TreeViewItem}">
			<Setter Property="Background" Value="Transparent"/>
			<Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
			<Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
			<Setter Property="Padding" Value="1,0,0,0"/>
			<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
			<Setter Property="FocusVisualStyle" Value="{StaticResource TreeViewItemFocusVisual}"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type TreeViewItem}">
						<Grid>
							<Grid.ColumnDefinitions>
								<ColumnDefinition MinWidth="19" Width="Auto"/>
								<ColumnDefinition Width="Auto"/>
								<ColumnDefinition Width="*"/>
							</Grid.ColumnDefinitions>
							<Grid.RowDefinitions>
								<RowDefinition Height="Auto"/>
								<RowDefinition/>
							</Grid.RowDefinitions>
							<ToggleButton x:Name="Expander" Style="{StaticResource ExpandCollapseToggleStyle}" IsChecked="{Binding Path=IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press"/>
							<Border x:Name="Bd" SnapsToDevicePixels="true" Grid.Column="1" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
								<Grid>
									<Grid.ColumnDefinitions>
										<ColumnDefinition Width="21.5"/>
										<ColumnDefinition Width="*" MinWidth="26.098"/>
									</Grid.ColumnDefinitions>
									<ContentPresenter HorizontalAlignment="Stretch" x:Name="PART_Header" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" ContentSource="Header" d:LayoutOverrides="Width" Grid.ColumnSpan="1" Grid.Column="1"/>
									<!--<Image Grid.ColumnSpan="1" Source="user.png" Width="16" Height="16" HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="None"/>-->
								</Grid>
							</Border>
							<ItemsPresenter x:Name="ItemsHost" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="1"/>
						</Grid>
						<ControlTemplate.Triggers>
							<Trigger Property="IsExpanded" Value="false">
								<Setter Property="Visibility" TargetName="ItemsHost" Value="Collapsed"/>
							</Trigger>
							<Trigger Property="HasItems" Value="false">
								<Setter Property="Visibility" TargetName="Expander" Value="Hidden"/>
							</Trigger>
							<Trigger Property="IsSelected" Value="true">
								<Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
								<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
							</Trigger>
							<MultiTrigger>
								<MultiTrigger.Conditions>
									<Condition Property="IsSelected" Value="true"/>
									<Condition Property="IsSelectionActive" Value="false"/>
								</MultiTrigger.Conditions>
								<Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
								<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
							</MultiTrigger>
							<Trigger Property="IsEnabled" Value="false">
								<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>

        <HierarchicalDataTemplate x:Key="ParentActivityTemplate" ItemsSource="{Binding Path=Children}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="21.5"/>
                    <ColumnDefinition Width="*" MinWidth="26.098"/>
                </Grid.ColumnDefinitions>
                <Image Grid.ColumnSpan="1" Width="16" HorizontalAlignment="Center" Source="/Microsoft.Research.ScientificWorkflow.TridentUtilities;component/Images/ManagementStudio/groups.png" VerticalAlignment="Center" Height="16" />
                <TextBlock Grid.Column="1" Margin="1,0,0,0" Text="{Binding Path=GroupName}" AutomationProperties.AutomationId="{Binding Path=GroupName}"/>
            </Grid>
        </HierarchicalDataTemplate>
    </Window.Resources>

	<Grid x:Name="LayoutRoot_Copy" Background="{x:Null}">
		<Border BorderBrush="#FFBDBDBD" BorderThickness="1,1,2,2" CornerRadius="4,4,4,4" Margin="0,0,0,0">
			<Border.Background>
				<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
					<GradientStop Color="#FFF7F7F7" Offset="0"/>
					<GradientStop Color="#FFF1F1F1" Offset="1"/>
				</LinearGradientBrush>
			</Border.Background>
			<Grid>
				<Grid.RowDefinitions>
					<RowDefinition Height="28"/>
					<RowDefinition Height="*"/>
					<RowDefinition Height="38"/>
				</Grid.RowDefinitions>
				<Border Name="brdrHeader" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Grid.Row="0" CornerRadius="4,4,0,0">
					<Border.Background>
						<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
							<GradientStop Color="#FFF7F7F7" Offset="0"/>
							<GradientStop Color="#FFE9E9E9" Offset="1"/>
						</LinearGradientBrush>
					</Border.Background>
					<Grid>
						<TextBlock HorizontalAlignment="Left" Margin="5,0,0,0" VerticalAlignment="Center" FontSize="14" Foreground="#FF5F5F5F" Text="Select Group" TextWrapping="Wrap"/>
						<Button HorizontalAlignment="Right" Margin="0,5.5,5,5.5" Style="{DynamicResource PopupCloseButton}" Width="17" Content="Button"  Command="{Binding Path=CancelCommand}"/>
					</Grid>
				</Border>
				<Button IsCancel="True" HorizontalAlignment="Right" Width="70" Content="Cancel" Margin="0,0,10,0" VerticalAlignment="Center" Grid.Row="2" Command="{Binding Path=CancelCommand}" />
				<Button IsDefault="True" HorizontalAlignment="Right" Width="70" Content="OK" Margin="0,0,85,0" VerticalAlignment="Center" Grid.Row="2" d:LayoutOverrides="Height" Command="{Binding Path=OkCommand}"/>
                                
				<Border Grid.Row="1" Background="#FFFFFFFF">
                    <Grid>
                    <TextBlock Grid.Row="1"  Visibility="{Binding  Path=HasNoGroup, Converter={StaticResource VisibilityConverter}}"
                                            Text="No groups to be displayed." Opacity="0.7" HorizontalAlignment="Center" VerticalAlignment="Top" AutomationProperties.AutomationId="AIdNoItems"
                                                  Margin="0,5,0,5"/>
					<ScrollViewer Visibility="{Binding  Path=HasGroup, Converter={StaticResource VisibilityConverter}}">
                        
						<TreeView Background="{x:Null}" BorderBrush="{x:Null}" ItemTemplate="{StaticResource ParentActivityTemplate}"
                  ItemsSource="{Binding Path=GroupList}" SelectedItemChanged="OnGroupChanged"/>
					</ScrollViewer>
                        </Grid>
				</Border>
			</Grid>
		</Border>
	</Grid>
</Window>